package com.woniu40.petai_manager.mapper;

import com.woniu40.petai_manager.entity.Manager;
import com.woniu40.petai_manager.vo.ManagerVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import javax.xml.crypto.Data;
import java.util.Date;
import com.woniu40.petai_manager.entity.Permission;
import com.woniu40.petai_manager.entity.Role;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@ResponseBody
public interface ManagerMapper {

    @Delete("delete from t_manager where manager_id=#{managerId}")
    int deleteByPrimaryKey(Integer managerId);

    int insert(ManagerVo managerVo);
    //可能没啥用
  /*  @Select("select * from t_manager where user_code=#{userCode}")
    Manager selectByPrimaryKey(Integer userCode);*/

    int insert(Manager record);

    List<Manager> selectAll();

   /* @Update("update t_manager set user_code=#{userCode},user_name=#{userName},cellphone=#{cellphone},email=#{email},password=#{password},locked=#{locked},insert_time=#{insertTime},update_time=#{updateTime}where manager_id=#{managerId}")
    int updateByPrimaryKey(Manager record);
*/


    @Select("SELECT * FROM t_manager WHERE user_name=#{userName}")
    Manager selectByPrimaryName(String userName);

    List<Permission> selectByRoleId(Integer roleId);


    //查询条件查询
    List<Manager> selectManagerByPage(@Param("userName")String userName);

    //添加到管理员和角色中间表
    int insertManagerRole(@Param("managerId") Integer managerId,@Param("roleIds") List<Integer> roleIds,@Param("date") Date date);

    //查询vo里面的  两表联查
   /* ManagerVo selectManagerVo(Integer managerId);*/
    //修改管理员
    int updateManager(ManagerVo managerVo);
    //修改时 删除管理员和角色
    int  deleteManagerAndRole(Integer managerId);

    //根据ID查询管理员
    @Select("select * from t_manager where manager_id=#{managerId}")
    ManagerVo selectByMid(Integer managerId);
}